package com.foreknow.demo0929;

import com.foreknow.demo0928.Pet;
import com.foreknow.demo0928.Dog;
import com.foreknow.demo0928.Penguin;

/**
 * 多态的应用
 */
public class TestSync {
    public Pet m1 (Pet[] pets) {
        return pets[0];
    }

    public static void main(String[] args) {
        Pet[] pets = new Pet[2];
        Dog dog = new Dog();
        dog.setName("三金");
        Penguin penguin = new Penguin();
        penguin.setName("QQ");
        pets[0] = dog;
        pets[1]= penguin;
        TestSync sync = new TestSync();
        Pet pet = sync.m1(pets);
        pet.toHospital();
    }

}
